<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .container {
      position: relative;
      width: 200px;
    }
    /*输入框样式*/
    .user-name {
      border: 1px solid rgba(0, 0, 0, 0.3);
      border-radius: 4px;
      height: 40px;
      width: 100%;
      box-sizing: border-box; /*怪异盒模型*/
      padding-right: 24px; /*留给小图标的空间*/
    }
    .user-name--icon {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translate(0, -50%);
      z-index: 10;
      cursor: pointer;
      font-size: 30px;
    }
    /*打钩*/
    .icon-gou {
      color: green;
    }
    /*打叉*/
    .icon-cha {
      color: red;
    }
  </style>
  <body>
    <div class="container">
      <input class="user-name" />
      <!-- 打钩图标 -->
      <span class="user-name--icon iconfont icon-gou"></span>
      <!-- 打叉图标 -->
      <!-- <span class="user-name--icon iconfont icon-cha"></span> -->
    </div>
  </body>
</html>